using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using WODPL.Controllers;
using WODPL.Models;


namespace WODPL.GameComponents
{
    public class GameWorld : GameComponentContainer
    {
        public GameWorld(Game game) : base(game)
        {
            var characterModel = new CharacterModel();
            var camera = new GameCamera(game.GraphicsDevice,characterModel);
            var stubMapTileRenderModel = new StubMapTileRenderModel(game.GraphicsDevice);
            Components.Add(new Character(game, camera, characterModel));
            for (var i = -1; i < 2; i++)
            {
                for (var j = -1; j < 2; j++)
                {
                    var dimensions = new Vector3(20, 20, 20);
                    var mapTileModel = new MapTileModel(new Vector3(i * 20, 0, j * 20), new BoundingBox(new Vector3(-dimensions.X / 2, -1, -dimensions.Z / 2), new Vector3(dimensions.X / 2, 0, dimensions.Z/2)), stubMapTileRenderModel);
                    var mapTile = new MapTile(game, camera, dimensions, mapTileModel);
                    mapTile.MapTileClicked +=
                        new CharacterMovementController(characterModel, mapTileModel).MoveCharacterToMapTile;
                    Components.Add(mapTile);
                }
            }
        }
    }
}